using UnityEngine;

public class CharacterRenderer : MonoBehaviour
{
	public GameObject arrow;
	public Color baseColor;

	public LineRenderer[] lines;

	public SpriteRenderer[] sprites;

	private float lerping;

	private Color hitColor = Color.red;

	private float hitTime = 0.5f;

	public void SetColor(Color c, bool init)
	{
		if (init)
		{
			baseColor = c;
		}
		LineRenderer[] array = lines;
		foreach (LineRenderer lineRenderer in array)
		{
			lineRenderer.startColor = c;
			lineRenderer.endColor = c;
			lineRenderer.sortingLayerName = "Default";
			lineRenderer.sortingOrder = 1;
		}
		SpriteRenderer[] array2 = sprites;
		foreach (SpriteRenderer spriteRenderer in array2)
		{
			spriteRenderer.sortingLayerName = "Default";
			spriteRenderer.sortingOrder = 1;
			spriteRenderer.color = c;
		}
	}

	private void Update()
	{
		if (arrow != null && gameObject.layer == LayerMask.NameToLayer("Player1") && !arrow.gameObject.activeInHierarchy)
		{
			arrow.gameObject.SetActive(true);
		}
		if (lerping > 0f)
		{
			lerping -= Time.deltaTime;
			Color c = Color.Lerp(baseColor, hitColor, lerping / hitTime);
			SetColor(c, init: false);
		}
	}

	public void FlashColorOnHit()
	{
		lerping = hitTime;
		SetColor(hitColor, init: false);
	}
}
